using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace SqlPrompt
{
	class DataColumn
	{
        public string Name { get; set; }
        public Type Type { get; set; }
        public int Size { get; set; }
        public bool IsLong { get; set; }

		public static DataColumn[] BuildFromSchemaTable(DataTable dtSchema)
		{
			DataColumn[] columns = new DataColumn[dtSchema.Rows.Count];
			for (int i = 0; i < columns.Length; i++)
			{
				DataColumn column = new DataColumn();
				column.Name = (string)dtSchema.Rows[i]["ColumnName"];
				if (string.IsNullOrEmpty(column.Name))
					column.Name = "[" + (i + 1) + "]";

				column.Type = (Type)dtSchema.Rows[i]["DataType"];
				column.Size = (int)dtSchema.Rows[i]["ColumnSize"];
				column.IsLong = (bool)dtSchema.Rows[i]["IsLong"];
				columns[i] = column;
			}

			return columns;
		}
	}
}
